<template>
  <div class="control-box">
    <div class="title">协议配置</div>
    <el-form :model="protocol" label-width="60px" class="demo-ruleForm" label-position="top">
      <el-form-item label="选择协议" prop="protocolname">
        <el-select v-model="protocol.protocolname" size="small" placeholder="请选择通道">
          <el-option
            v-for="item in protocolList"
            :key="item.no"
            :label="item.name"
            :value="item.no"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="通讯机通道号" prop="commchannelid">
        <el-input v-model="protocol.commchannelid" size="small" placeholder="请选择通道"></el-input>
      </el-form-item>
      <el-form-item label="通讯机编号" prop="commid">
        <el-input v-model="protocol.commid" size="small" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="通讯间隔" prop="commjiange">
        <el-input v-model="protocol.commjiange" size="small" placeholder="请输入" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    protocol: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      value: "",
      protocolList: null
    };
  },
  created() {
    this._getProtocolList();
  },
  methods: {
    _getProtocolList() {
      return this.$axios
        .get("fes/drop/queryProtocoltype?table=fes_protocoltype")
        .then(res => {
          if (res.code === 1) {
            this.protocolList = res.data;
          } else {
            throw res.msg;
          }
        });
    }
  }
};
</script>

<style lang="scss" scoped>
.control-box {
  position: relative;
  padding: 22px 16px;
  padding-bottom: 0;
  border: 1px solid #dcdfe6;
  .title {
    position: absolute;
    top: 0;
    left: 20px;
    transform: translateY(-50%);
    padding: 0 20px;
    background: #fff;
  }
}
</style>
